package com.dubbo.mapper;

import com.dubbo.domain.Shipping;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.Map;

/**
 * 物流Mapper
 * @author wujunyuan
 * @date 2018年12月18日  下午4:17:12
 */
public interface ShippingMapper extends Mapper<Shipping>{

	/**
	 * 根据订单号获取物流单号
	 * @author chenluqiang
	 * @date 2019年1月3日 下午5:01:13 
	 * @param orderId
	 * @return
	 */
	@Select("SELECT " + 
			"	osg.shippingCode, " + 
			"	osg.shippingName " + 
			"FROM " + 
			"	o_shipping osg " + 
			"LEFT JOIN o_order oor ON oor.shippingId = osg.id " + 
			"WHERE " + 
			"	oor.id = #{orderId}")
	Map<String,Object> getShippingCodeByOrderId(@Param("orderId") String orderId);
	
	/**
	 * 根据订单号获取物流信息
	 *
	 * @author lihongwu
	 * 2019年1月18日 下午5:55:14
	 * @param orderId
	 * @return
	 */
	@Select("SELECT " + 
			"	oh.id, " + 
			"	oh.addressee, " + 
			"	oh.addresseePhone, " + 
			"	oh.address " + 
			"FROM " + 
			"	o_shipping oh " + 
			"JOIN o_order o ON oh.id = o.shippingId " + 
			"WHERE " + 
			"	o.id = #{orderId}")
	Shipping  getShippingByOrderId(@Param("orderId") String orderId);
	
}